package com.gitee.xhs.sampleRecod.transactionRecord;

import com.gitee.xhs.sourceIterator.AbstractSourceIterator;

import java.sql.Timestamp;

/**
 * @author BigHead
 * @date 2022/7/26 10:06
 * @description AbstractTransactionIterator
 */
public abstract class AbstractTransactionIterator extends AbstractSourceIterator<Transaction> {

    protected static final Timestamp INITIAL_TIMESTAMP = Timestamp.valueOf("2022-06-28 00:00:00");

    protected static final long SIX_MINUTES = 6 * 60 * 1000;

    protected static final int DEFAULT_BOUNDED = 50;


    protected final boolean bounded;

    protected final int maxBounded;

    protected long timestamp;

    protected final long intervalTimeStamp;

    protected final boolean useOutTimeStamp;

    protected int index = 0;

    protected final AbstractTransactionMockerInterceptor abstractTransactionMockerInterceptor;

    /**
     * @param bounded                              数据有界标记
     * @param abstractTransactionMockerInterceptor Mocker生成类
     * @param maxBounded                           最大生成界限
     * @param initialTimeStamp                     数据初始化生成时间
     * @param intervalTimeStamp                    间隔时间
     */
    public AbstractTransactionIterator(boolean bounded, AbstractTransactionMockerInterceptor abstractTransactionMockerInterceptor, Integer maxBounded, Long initialTimeStamp, Long intervalTimeStamp, Boolean useOutTimeStamp) {
        this.bounded = bounded;
        this.abstractTransactionMockerInterceptor = abstractTransactionMockerInterceptor;

        if (null == maxBounded) {
            this.maxBounded = DEFAULT_BOUNDED;
        } else {
            this.maxBounded = maxBounded;
        }

        if (null == initialTimeStamp) {
            this.timestamp = INITIAL_TIMESTAMP.getTime();
        } else {
            this.timestamp = initialTimeStamp;
        }

        if (null == intervalTimeStamp) {
            this.intervalTimeStamp = SIX_MINUTES;
        } else {
            this.intervalTimeStamp = intervalTimeStamp;
        }

        if (null == useOutTimeStamp) {
            this.useOutTimeStamp = false;
        } else {
            this.useOutTimeStamp = useOutTimeStamp;
        }
    }

}
